/**
 * @FileName: SendTopic.java
 * @Package: com.rabbitmq
 * @author lig134
 * @created 2017/3/9 14:38
 * <p>
 * Copyright 2015 ziroom
 */
package com.rabbitmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * <p></p>
 * topic类型消息
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author lig134
 * @since 1.0
 * @version 1.0
 */
public class SendTopic {

    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory connFac = new ConnectionFactory();
        connFac.setHost("master");
        connFac.setUsername("ligen");
        connFac.setPassword("ligen");
        //创建一个连接
        Connection conn = connFac.newConnection();

        //创建一个渠道
        Channel channel = conn.createChannel();
        String exchangeName="exchange03";
        String messageType="fs.type01";
        String messageType1="type01";
        String messageType2="ts.type01";
        String messageType3="ts.type02";
        channel.exchangeDeclare(exchangeName,"topic");
        //定义参数名
        String msf="Hello World!";
        channel.basicPublish( exchangeName , messageType , null , (msf+"1").getBytes());
        channel.basicPublish( exchangeName , messageType2 , null , (msf+"2").getBytes());
        channel.basicPublish( exchangeName , messageType3 , null , (msf+"3").getBytes());
        channel.basicPublish(exchangeName,messageType1,null,(msf+"4").getBytes());
        System.out.println("send message[" + msf + "] to "+ exchangeName +" success!");

        channel.close();
        conn.close();
    }



}